home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / propage / pagegenies / avery labels.pgen < prev    next >
Text File  |  1992-03-12  |  6KB  |  261 lines

  1. /*
  2. @B@LLabel Generator.pprx@b Copyright Gold Disk Inc., February, 1992
  3. This Genie will read one of several Avery Label databases contained in the current directory and allow the user to create a variety of labels.
  4. */
  5. parse arg sourcedir
  6. cr  = '0a'x
  7. address command
  8. call SafeEndEdit.rexx()
  9. call ppm_AutoUpdate(0)
  10. units = getclip(ppgenie_units)
  11. call ppm_SetUnits(1)
  12.  
  13. labels = ''
  14. counter = 0
  15.  
  16. address command
  17. list    = getdirlist.rexx(sourcedir, ".db")
  18. if list = '' then exit_msg("Unable to find label data:ase. Please reinstall!")
  19.  
  20. selection = ppm_SelectFromList("Select Type of label..", 35, 5, 0, list)
  21. if selection = '' then exit_msg()
  22.  
  23. filename = sourcedir"/"selection".db"
  24.  
  25. if ~open(file, filename, "r") then exit_msg("An error has occured reading database")
  26.  
  27. call ppm_ShowStatus("Reading label database..")
  28.  
  29. line    = readln(file)
  30.  
  31. if pos('LASER', line) ~= 0 then
  32.     labeltype = laser
  33. else if pos('MATRIX', line) ~= 0 then
  34.     labeltype = matrix
  35. else
  36.     exit_msg("Invalid database file")
  37.  
  38. spos = Pos('PAGESIZE', line)
  39.  
  40. if spos ~= 0 then
  41. do
  42.     line = substr(line, spos + 8)
  43.     opageh    = word(line, 2)
  44.     opagev    = word(line, 1)
  45. end
  46. else
  47. do
  48.     opageh    = 0
  49.     opagev    = 0
  50. end
  51.  
  52.  
  53. lcounter = 0
  54.  
  55. do while ~eof(file)
  56.  
  57.     line = strip(readln(file))
  58.  
  59.     if line = '' | left(line, 2) = '\*' | left(line, 2) = '*/' then
  60.         iterate
  61.     
  62.     lcounter = lcounter + 1
  63.  
  64.     parse var line code ';' name ';' .
  65.  
  66.     code = strip(code)
  67.     name = strip(name)
  68.     text = code || copies(" ", max(1,12 - length(code))) || name
  69.  
  70.     lines.lcounter.0    = line
  71.     lines.lcounter.1    = text
  72.  
  73.     labels = labels||cr||text
  74.  
  75. end
  76.  
  77. labels = delstr(labels,1,1)
  78. label = ppm_SelectFromList("Select Label..", 40, 10, 0, labels)
  79. if label = '' then exit_msg()
  80.  
  81. do i = 0 to lcounter - 1
  82.  
  83.     cline = lines.i.1
  84.     if cline = label then leave
  85.  
  86. end
  87.  
  88. line = lines.i.0
  89.  
  90. group = 0
  91.  
  92. if ppm_GroupFirstBox() ~= 0 then
  93. do
  94.     if ppm_Inform(2,"Would like like to tile the current group to create labels?", "No","Yes") then group = 1
  95. end
  96. else if ppm_BoxNum() ~= 0 then
  97. do
  98.     if ppm_BoxPage() ~= 0 then
  99.         if ppm_Inform(2,"Would like like to tile the current box to create labels?", "No","Yes") then group = 2
  100. end
  101.  
  102. if labeltype = laser then
  103. do
  104.     sline = compress(line)
  105.     parse var sline pnum ';' type ';' lheight ';' lwid ';' cols ';' rows ';' topmarg ';' sidemarg ';' hpitch ';' vpitch ';' .
  106.  
  107.     if ~exists("rexx:GroupTile.pprx") then
  108.         exit_msg("Unable to locate Genie named: rexx:GroupTile.pprx")
  109.  
  110.     npages = ppm_GetForm("How many pages will you need?", 8, "Pages:1")
  111.     if npages = '' then exit_msg()
  112.  
  113.     if ~datatype(npages, n) then exit_msg("Invalid entry")
  114.  
  115.     newpage = ppm_CreatePage(ppm_CurrentPage() + 1,1,0,0,0)
  116.  
  117.     if opagev ~= 0 then
  118.         call ppm_SetPageSize(newpage, opagev, opageh)
  119.  
  120.     call ppm_GotoPage(newpage)
  121.  
  122.     if group = 2 then
  123.     do
  124.         call ppm_NewGroup()
  125.         call ppm_AddToGroup(ppm_BoxNum())
  126.         call TileGroup(sidemarg,topmarg,lwid, lheight, cols, rows, hpitch, vpitch)
  127.     end
  128.     else if group = 1 then
  129.     do
  130.         call TileGroup(sidemarg,topmarg,lwid, lheight, cols, rows, hpitch, vpitch)
  131.     end
  132.     else
  133.     do
  134.         call ppm_NewGroup()
  135.         box = ppm_CreateBox(sidemarg, topmarg, lwid, lheight, 0)
  136.         call ppm_AddToGroup(box) 
  137.         call TileGroup(sidemarg,topmarg,lwid,lheight,cols,rows, hpitch, vpitch)
  138.     end
  139.  
  140.     message = "Done"
  141.  
  142. end
  143. else
  144. do
  145.     sline = compress(line)
  146.     parse var sline pnum ';' type ';' lheight ';' lwid  ';' cols ';' cwidth ';' hpitch ';' vpitch ';' .
  147.  
  148.     npages = ppm_GetForm("How many Pages of Dot Matrix Labels?", 18, "Number of labels:"1)
  149.     if npages = '' then exit_msg()
  150.  
  151.     if ~datatype(npages, n) then exit_msg("Invalid input")
  152.  
  153.     if vpitch < 1 then vpitch = 1
  154.  
  155.     hspace = hpitch - lwid
  156.     lmarg = (cwidth - (cols * hpitch - hpitch + lwid)) / 2
  157.     tmarg = (vpitch - lheight) / 2
  158.  
  159.     newpage = ppm_CreatePage(ppm_CurrentPage() + 1, 1, 0, 0, 0)
  160.     call ppm_SetPageSize(newpage, cwidth, vpitch)
  161.     call ppm_GotoPage(newpage)
  162.  
  163.     if group = 2 then
  164.     do
  165.         call ppm_NewGroup()
  166.         call ppm_AddToGroup(ppm_BoxNum())
  167.         call TileGroup(lmarg,tmarg,lwid, lheight, cols, 1, hpitch, vpitch)
  168.     end
  169.     else if group = 1 then
  170.     do
  171.         call TileGroup(lmarg,tmarg,lwid, lheight, cols, 1, hpitch, vpitch)
  172.     end
  173.     else
  174.     do
  175.         call ppm_NewGroup()
  176.         box = ppm_CreateBox(lmarg, tmarg, lwid, lheight, 0)
  177.         call ppm_AddToGroup(box) 
  178.         call TileGroup(lmarg,tmarg,lwid, lheight, cols, 1, hpitch, vpitch)
  179.         call ppm_DeleteBox(box)
  180.     end
  181.  
  182.     call ppm_SetDMEject(0)
  183.     call ppm_SetDMPageSize(cwidth, vpitch)
  184.  
  185.     cwidth = ppm_ConvertUnits(1, units, cwidth)
  186.     vpitch = ppm_ConvertUnits(1, units, vpitch)
  187.  
  188.     if units = 1 then unit = "inches"
  189.     else if units = 2 then unit = "CM"
  190.     else if units = 3 then unit = "Picas"
  191.  
  192.     message = "Done. The Dot Matrix Page Eject has been turned off and the output page size has been set to "cwidth" "unit" x "vpitch" "unit
  193.  
  194. end
  195.     
  196. npages = npages - 1
  197. cpage = ppm_CurrentPage()
  198.  
  199. do npages
  200.  
  201.     call ppm_CopyPage(cpage, cpage + 1, 1)
  202.     cpage = cpage + 1
  203.  
  204. end
  205.  
  206. exit_msg(message)
  207.  
  208. exit_msg: procedure expose units
  209. do
  210.     parse arg message
  211.  
  212.     if message ~= '' then call ppm_Inform(1,message,)
  213.     call ppm_ClearStatus()
  214.     call ppm_SetUnits(units)
  215.     call ppm_AutoUpdate(1)
  216.     exit
  217. end
  218.  
  219. TileGroup: procedure expose newpage
  220. do
  221.     parse arg sidemarg, topmarg, lwid, lheight, cols, rows, hpitch, vpitch
  222.  
  223.     i = 0
  224.  
  225.     box = ppm_GroupFirstBox()
  226.  
  227.     do while box ~= 0
  228.  
  229.         i = i + 1
  230.         newbox.i = ppm_CloneBox(box, 0, 0)
  231.  
  232.         if ppm_TextOverFlow(box) then
  233.         do
  234.             call ppm_DeleteContents(newbox.i)
  235.             call ppm_TextIntoBox(newbox.i, ppm_GetArticleText(box, 1))
  236.         end
  237.  
  238.         call ppm_BoxChangePage(newbox.i, newpage)
  239.         box = ppm_GroupNextBox(box)
  240.  
  241.     end
  242.  
  243.     call ppm_NewGroup()
  244.  
  245.     do x = 1 to i
  246.         call ppm_AddToGroup(newbox.x)
  247.     end
  248.  
  249.     grouprect = ppm_GetGroupRect()
  250.     xscale = lwid / word(grouprect, 3) * 100
  251.     yscale = lheight / word(grouprect, 4) * 100
  252.     address command
  253.     call GroupScale.pprx(xscale, yscale)
  254.  
  255.     xsp = hpitch - lwid
  256.     ysp    = vpitch - lheight
  257.  
  258.     call GroupTile.pprx(sidemarg, topmarg, rows, cols, xsp, ysp)
  259.     return
  260. end
  261.